from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from changliang import LUJING
import time

wd = webdriver.Chrome(service=Service(LUJING))
wd.implicitly_wait(10)
wd.get('http://127.0.0.1')

#登陆
wd.find_element(By.CSS_SELECTOR,'#username').send_keys('byhy')
wd.find_element(By.CSS_SELECTOR,'#password').send_keys('88888888')
wd.find_element(By.CSS_SELECTOR,'button[type]').click()

#UI-0101
rs1_ele =  wd.find_elements(By.XPATH,"//ul[@class='sidebar-menu tree']/li[@class='header']/following-sibling::*[position()<=3]")
if rs1_ele[0].text == '客户' and rs1_ele[1].text == '药品' and rs1_ele[2].text == '订单':
    print('ui-0101测试通过')
else:
    print('ui-0101测试有误')

#UI-0102
# wd.find_element(By.CSS_SELECTOR,"ul[class='sidebar-menu tree'] li:nth-of-type(2)").click()
# wd.find_element(By.CSS_SELECTOR,'button[type]').click()
# ele_ments = wd.find_elements(By.CSS_SELECTOR,'section input')
# ele_ments[0].send_keys('南京中医院')
# ele_ments[1].send_keys('18628904684')
# wd.find_element(By.CSS_SELECTOR,'section textarea').send_keys('南京省武汉路')
# wd.find_element(By.CSS_SELECTOR,"div[class='col-lg-12 col-md-12 col-sm-12']>button:nth-of-type(1)").click()



#UI-0103
rs_ele = wd.find_element(By.CSS_SELECTOR,'div[class="search-result-item"] label:nth-child(1)')
rs_ele.click()
ele_ments_0103 = wd.find_elements(By.CSS_SELECTOR,'div[class="search-result-item"] input')
ele_ments_0103[0].clear()
ele_ments_0103[0].send_keys('北京省中医yuan')
ele_ments_0103[1].clear()
ele_ments_0103[1].send_keys('26558822')
wd.find_element(By.XPATH,'//div[@class="search-result-item"] [1]//label[1]').click()
time.sleep(3)
